<?php

class JobeetCategory extends BaseJobeetCategory
{
  public function getActiveJobsCriteria()
  {
    $criteria = new Criteria();
    $criteria->add(JobeetJobPeer::CATEGORY_ID, $this->getId());
 
    return JobeetJobPeer::addActiveJobsCriteria($criteria);
  }
	
  
	public function getActiveJobs($max = 10)
	{
	  $criteria = $this->getActiveJobsCriteria();
	  $criteria->setLimit($max);
	 
	  return JobeetJobPeer::doSelect($criteria);
	}
	 
	public function countActiveJobs()
	{
	  $criteria = $this->getActiveJobsCriteria();
	  $criteria->add(JobeetJobPeer::CATEGORY_ID, $this->getId());
	 
	  return JobeetJobPeer::doCount($criteria);
	}
  
  
  public function setName($name)
  {
    parent::setName($name);
 
    $this->setSlug(Jobeet::slugify($name));
  }
      	
  public function __toString()
  {
    return $this->getName();
  }
}
